<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
/********************
 *@param function:Clickr 訂單信息
 *@param datetime 2012-01-12
 *@param author abin
 ********************/
class Pays extends Admins_Controller {
	private $data=array();
	public function __construct(){
       parent::__construct();
       $this->data['currentPage']='systems';
       $this->load->model('orders_mdl');
    //查詢語言
    $this->load->model('languages_mdl');
    $this->data['format_time']=$this->settings['default_time'];
	$this->data['lang'] =$this->lang->language;
  }
	public function index(){
		$this->data['lists'] = $this->orders_mdl->get_payments();
		
		$this->load->view('admins/pays_lists_view',$this->data);
	}
	public function setup(){
		$this->data['code'] = $this->input->get('code',TRUE);
		$this->data['row'] = $this->orders_mdl->get_one_payment($this->data['code']);
		if(empty($this->data['row'])){
			show_error('對不起,參數出錯!');
		}
		if(!empty($this->data['row']['options'])){
			$this->data['options'] = unserialize($this->data['row']['options']);
		}
		$this->load->view('admins/pays_'.$this->data['code'].'_view',$this->data);
	}
	public function setupsave(){
		$options = $this->input->post('options');
		$options = serialize($options);
		$code = $this->input->post('code');
		$data['options'] = $options;
		$data['status'] = (int)$this->input->post('status');
		$data['sort'] = (int)$this->input->post('sort');
		$result = $this->orders_mdl->update_payment($code,$data);
		$msg = $result ?$this->data['lang']['global_lable_48']:$this->data['lang']['global_lable_49'];
        $notify = $result?'success':'error';
        $this->nsession->set_flashdata($notify, $msg);
        $redirect=site_url("admins/pays/index");//獲取列表篩選參數
        redirect($redirect);
	}
}